#define _CRT_SECURE_NO_WARNINGS 1 
#include "vector.h"
#include<list>

template<class Container>
void Print(const Container& c)
{
	for (const auto& e : c)
	{
		cout << e << " ";
	}
	cout << endl;
}

void test1()
{
	cgc::vector<int> v;
	v.push_back(10);
	v.push_back(20);
	v.push_back(3);
	v.push_back(4);
	v.push_back(6);

	Print(v);

	v.pop_back();
	v.pop_back();
	v.pop_back();
	v.pop_back();
	v.pop_back();
	v.pop_back();

	Print(v);
}

void test2()
{
	cgc::vector<int> v;
	v.push_back(10);
	v.push_back(20);
	v.push_back(3);
	v.push_back(4);
	v.push_back(6);

	v.insert(v.begin(), 3);
	Print(v);
	v.insert(v.end(), 60);
	Print(v);
	v.erase(v.begin());
	Print(v);
	v.erase(v.end() - 1);
	Print(v);
}
void test3()
{
	cgc::vector<int> v;
	v.push_back(10);
	v.push_back(20);
	v.push_back(3);
	v.push_back(4);
	v.push_back(6);
	v.push_back(7);
	v.push_back(8);
	v.resize(2,1);
	Print(v);
}

void test4()
{
	cgc::vector<int> v1 = { 1,2,3,4,5,10};
	cgc::vector<int> v2 = { 1,2,3,4,5,6 };
	Print(v2);
	auto v3 = v2;
	Print(v3);
	v3 = v1;
	Print(v3);
	string s1 = "abced";
	cgc::vector<int> v4(v1.begin(), v1.end() - 1);
	Print(v4);
	cgc::vector<int> v5(s1.begin(), s1.end());
	Print(v5);


}

void test5()
{
	cgc::vector<int> v1 = { 1,2,3,4,5,10 };
	auto it = v1.rbegin();
	while (it != v1.rend())
	{
		cout << *it << " ";
		++it;
	}

	cout << endl;
}
int main()
{
	//test1();
	//test2();
	//test3();
	//test5();
	int array[] = { 1, 2, 3, 4, 0, 4,0 , 5, 6, 7, 8, 9 };

	int n = sizeof(array) / sizeof(int);

	list<int> mylist(array, array + n);

	auto it = mylist.begin();

	while (it != mylist.end())

	{

		if (*it != 0)

			cout << *it << " ";

		else

			it = mylist.erase(it);

		++it;

	}
	return  0;
}